package com.swxc.smartorder.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.swxc.smartorder.ui.fragment.OrderFragment;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;

/**
 * Author   Administrator
 * Date     2018/3/29
 * Desc     eg
 *
 * @author Administrator
 */
public class AdapterTab extends FragmentPagerAdapter {

    private ArrayList<String> mTitleList;

    public AdapterTab(FragmentManager fm) {
        super(fm);
    }

    public AdapterTab(@Nullable FragmentManager supportFragmentManager, @NotNull ArrayList<String> mTitleList) {
        super(supportFragmentManager);
        this.mTitleList = mTitleList;
    }

    @Override
    public Fragment getItem(int position) {
        OrderFragment fragment = OrderFragment.newInstance(mTitleList.get(position));
        return fragment;
    }

    @Override
    public int getCount() {
        return mTitleList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {

        String title = "";
        switch (mTitleList.get(position)) {
            case "all":
                title = "全部工单";
                break;
            case "accepted":
                title = "我受理中";
                break;
            case "commited":
                title = "我提交的";
                break;
            case "untreated":
                title = "待接工单";
                break;
            default:
                break;
        }
        return title;
    }
}
